package com.study.system.utils;

import com.auth0.jwt.interfaces.DecodedJWT;
import jakarta.servlet.http.HttpServletRequest;

public class RequestUtil {

    // 从请求头中获取用户id
    public static Integer getUserId(HttpServletRequest request) {
        String token = request.getHeader("token");
        DecodedJWT decode = JWTUtil.verifyToken(token);
        String userIdString = decode.getClaim("id").asString();
        return Integer.parseInt(userIdString);
    }

}
